#include <glib.h>

typedef struct my_data_tag {
    gint x;
    gint y;
}my_data_t;

static void g_datalist_id_test (void)
{
    GData *list = NULL;
    my_data_t *data1 = NULL;
    my_data_t *data2 = NULL;
    my_data_t *data3 = NULL;
    my_data_t *ret = NULL;

    g_datalist_init (&list);

    data1 = g_new0(my_data_t, 1);
    data1->x = 101;
    data1->y = 201;
    data2 = g_new0(my_data_t, 1);
    data2->x = 102;
    data2->y = 202;
    data3 = g_new0(my_data_t, 1);
    data3->x = 103;
    data3->y = 203;

    g_print("data1->x(%p): %d, data1->y(%p):%d \n", &data1->x, data1->x, &data1->y, data1->y);

    g_datalist_id_set_data (&list, g_quark_from_string ("one"), data1);
    g_datalist_id_set_data (&list, g_quark_from_string ("two"), data2);
    g_datalist_id_set_data (&list, g_quark_from_string ("three"), data3);

    ret = g_datalist_id_get_data (&list, g_quark_from_string ("one"));
    g_print("ret->x(%p): %d, ret->y(%p):%d \n", &ret->x, ret->x, &ret->y, ret->y);

    g_free(data1);
    g_free(data2);
    g_free(data3);
    g_datalist_clear (&list);
}

int main (int argc, char** argv)
{
    g_datalist_id_test();

    return 0;
}
